package com.smart.status.payment.controller;

import com.smart.status.payment.alipay.AlipayPaymentHandler;
import com.smart.status.payment.alipay.vo.AlipayPaymentVo;
import com.smart.status.payment.handler.PaymentHandler;
import com.smartStatus.core.util.R;
import com.smartStatus.security.annoation.Ignore;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: liuby5
 * @CreateTime: 2022-09-07  16:18
 * @Description: 支付系统测试
 * @Version: 1.0
 */
@RestController
@RequestMapping("/payment")
public class PaymentController {
    @Resource
    Map<String, PaymentHandler> paymentHandler;


    /**
     * 扫码支付
     *
     * @return
     */
    @Ignore(value = false)
    @GetMapping("/sign-pay")
    public R testSignPayment() {
        PaymentHandler aLiPay = paymentHandler.get("A_LI_PAY");
        AlipayPaymentVo alipayPaymentVo = new AlipayPaymentVo();
        return aLiPay.verificationCodePay(alipayPaymentVo);
    }


    @Ignore(value = false)
    @GetMapping("/refund-pay")
    public R testRefundPay(){
        PaymentHandler aLiPay = paymentHandler.get("A_LI_PAY");
        AlipayPaymentVo alipayPaymentVo = new AlipayPaymentVo();
        return aLiPay.refundPay(alipayPaymentVo);
    }

    @Ignore(value = false)
    @GetMapping("/refund-result-query")
    public R testRefundResultQuery(){
        PaymentHandler aLiPay = paymentHandler.get("A_LI_PAY");
        AlipayPaymentVo alipayPaymentVo = new AlipayPaymentVo();
        return aLiPay.refundQuery(alipayPaymentVo);
    }

    @Ignore(value = false)
    @GetMapping("/order-detail-query")
    public R testOrderDetailQuery(){
        PaymentHandler aLiPay = paymentHandler.get("A_LI_PAY");
        AlipayPaymentVo alipayPaymentVo = new AlipayPaymentVo();
        return aLiPay.orderDetailQuery(alipayPaymentVo);
    }


    @Ignore(value = false)
    @GetMapping("/app-sign-pay")
    public R testAppSignPayment(AlipayPaymentVo paymentVo){
        PaymentHandler aLiPay = paymentHandler.get("A_LI_PAY");
        AlipayPaymentVo alipayPaymentVo = new AlipayPaymentVo();
        return aLiPay.appSignPay(alipayPaymentVo);
    }

}
